package cc.mrbird.febs.common.entity;

import org.springframework.http.HttpStatus;

import java.util.HashMap;

public class LayuiResponse extends HashMap<String, Object> {
    private static final long serialVersionUID = -8713837118340960775L;
    public LayuiResponse code(HttpStatus status) {
        this.put("code", status.value());
        return this;
    }

    public LayuiResponse message(String message) {
        this.put("message", message);
        return this;
    }
    public LayuiResponse count(int count) {
        this.put("count", count);
        return this;
    }


    public LayuiResponse data(Object data) {
        this.put("data", data);
        return this;
    }

    public LayuiResponse success() {
        this.code(HttpStatus.OK);
        return this;
    }

    public LayuiResponse fail() {
        this.code(HttpStatus.INTERNAL_SERVER_ERROR);
        return this;
    }
    @Override
    public LayuiResponse put(String key, Object value) {
       super.put(key, value);
        return this;
    }
}
